package com.example.controller;

import com.example.common.Result;
import com.example.entity.TreeTypeName;
import com.example.service.TreeService;
import com.example.service.TypeNameService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/treename")
public class TypeNameController {

    @Resource
    private TypeNameService treeNameService;

    @PostMapping("/typename")
    public Result typename(TreeTypeName treeTypeName){
        List<TreeTypeName> treelist = treeNameService.selectTypeName(treeTypeName);
        return Result.success(treelist);
    }

    //商家我的树苗页面加载所有树苗种类名称
    @GetMapping("/loadtreetypename")
    public Result loadTreetypename(){
       List<String> list = treeNameService.loadTreetypename();
        return Result.success(list);
    }
    //商家树苗详情页面交换树苗时加载所有树苗种类名称
    @PostMapping("/loadtreename/{userId}")
    public Result loadTreetypename(@PathVariable Integer userId){
        List<String> list = treeNameService.loadTreename(userId);
        return Result.success(list);
    }

}
